<?php
namespace App\Admin\Models;
use Common\BaseModel;
class HomeAdCofig extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function initialize()
    {
        parent::initialize();
        $this->setSource('view_home_ad_cofig');
    }

    public function find_list($ids=''){
        $cate_info = $this->findFirstById($ids);
        if(!$cate_info){
            $ids = '-1';
        }else{
            $ids = $cate_info->ids?$cate_info->ids:-1;
        }

        $homeAdDb = new ViewHomeAd();
        $list = $homeAdDb->get_ids($ids);
        return $list;
    }

    public function get_list($ids=''){
        $conditions ="";
        if($ids){
            $conditions = "id in($ids)";
        }
        $list = $this->find(array(
            $conditions
        ));
        return $list;
    }

    /**
     * @func 根据版本id 查找版本
     * @param $id
     * @return array
     */
    public function find_by_id($id){
        if(empty($id)){
            return [];
        }
        $cate_info = $this->findFirstById($id);
        if($cate_info){
            return $cate_info->toarray();
        }else{
            return [];
        }
    }

    /**
     * @func 根据版本id 查找版本
     * @param $id
     * @return array
     */
    public function find_by_id_obj($id){
        return $this->findFirstById($id);
    }

    public function save_params($params){
        return $this::save($params);
    }

}
